package com.vecspace.dicttable;

/**
 * @author: wanghua
 */

public class CodeService implements ICodeDataSource{

	CodeDao dao;
	
	@Override
	public CodeTable fillDMTable(String tableName, String codeField, 
			String nameField, String parentField, String orderByField){		
		CodeTable table = null;
		try {
			table = dao.fillDMTable(tableName, codeField, nameField, parentField, orderByField);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return table;
	}	
	 
	@Override
	public CodeTable fillDMTableFromDictAll(String codeType, String tableName,String codeTypeField, String codeField, 
			String nameField, String parentField, String orderByField){
		CodeTable table = null;
		try {
			table = dao.fillDMTableFromDictAll(codeType, tableName, codeTypeField, codeField, nameField, parentField, orderByField);
		} catch (Exception e) {
			e.printStackTrace(); 
		}
		return table;
	}
	
	@Override
	public String getCodeName(String tableName, String codeField, String nameField, String code) {
		try {
			String name = dao.getCodeName(tableName, codeField, nameField, code);
			return name;
		} catch (Exception e) {
			e.printStackTrace();
			return code;
		}
	}
	
	@Override
	public String getCodeNames(String tableName, String codeField, String nameField, String codes) {
		try {
			String names = dao.getCodeNames(tableName, codeField, nameField, codes);
			return names;
		} catch (Exception e) {
			e.printStackTrace();
			return codes;
		}
	}
	
	public CodeDao getDao() {
		return dao;
	}
	public void setDao(CodeDao dao) {
		this.dao = dao;
	}
}
